-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add trace correlation, breadcrumbs, and structured logging to Sentry sink #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add trace correlation, breadcrumbs, and structured logging to Sentry sink #90
Conversation
Summary of ChangesHello @francesco-carrella, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request significantly enhances the @logtape/sentry sink by adding modern observability features like trace correlation, breadcrumbs, and structured logging. The implementation is well-structured and follows Sentry's best practices. My review focuses on a correctness issue in the backward-compatibility layer that affects message grouping, and a small refactoring opportunity to improve code clarity. Overall, this is a great contribution that brings valuable features to the Sentry integration.
The Sentry sink now provides comprehensive observability features for production debugging, including automatic trace correlation, breadcrumbs, and structured logging support via Sentry's Logs API. - Add automatic trace context capture from active Sentry spans (trace_id, span_id) - Add enableBreadcrumbs option to create breadcrumbs for debugging context - Add captureAsEvents option to control which log levels become Sentry events - Add automatic structured logging support (Sentry SDK v9.41.0+ with enableLogs: true) - Add ParameterizedString support for better message grouping in Sentry - Add beforeSend hook for transforming/filtering records - Modernize API to use global Sentry functions (v8+ pattern) - Maintain backward compatibility with v1.1.x client-based pattern
352990a to
4efa09e
Compare
|
Could you update the lockfile? |
Add trace correlation, breadcrumbs, and structured logging to Sentry sink
Summary
Adds observability features to
@logtape/sentryfor distributed systems debugging:Impact: ~270 LOC, 100% backward compatible, zero new dependencies
Why
The current
@logtape/sentryintegration (v1.1.x) works correctly but lacks observability features needed for distributed systems. When using LogTape with Sentry's tracing and performance monitoring, there's no way to correlate logs with traces, no debugging context trail via breadcrumbs, and messages with dynamic values create separate issues instead of grouping together.This PR addresses these gaps while maintaining backward compatibility and cross-runtime support.
Compliance with Sentry Guidelines
This implementation follows official Sentry SDK development guidelines:
Uses Global Functions (Not Multiple Clients)
Following Sentry Best Practices, which state:
The sink uses global Sentry functions (
captureMessage,captureException,getActiveSpan) instead of client instances. The v1.1.x client-based pattern is deprecated but remains functional for backward compatibility.Logging Protocol Compliance
Implements features from Sentry SDK Logging Protocol:
enableLogs: trueconfiguration (lines 327-340)JavaScript Logging Standards
Meets requirements from Sentry JavaScript Logs Documentation:
Feature Comparison
Comparison with other Sentry logging integrations:
Reference: Based on official Pino transport and community Winston transports.
What Changed
1. Automatic Trace Correlation (lines 304-312)
Captures
trace_id,span_id, andparent_span_idfrom active Sentry spans. Always enabled with zero overhead if no active span exists. Uses Sentry v8+getActiveSpan()API.2. Optional Breadcrumbs (lines 315-324)
Adds logs as breadcrumbs to provide debugging context trail. Opt-in via
enableBreadcrumbs: true.3. Structured Logging Support (lines 327-340)
Automatic support for Sentry's Logs API (v9.41.0+). Users enable it in their Sentry config:
Uses
_INTERNAL_captureLog(same approach as official Pino transport). Public wrapper APIs are in development (#15717).Note: The official Pino transport only supports structured logging. This PR adds trace correlation, breadcrumbs, message grouping, and events support.
4. Enhanced Event Capture (lines 343-358)
Configurable event levels with special error handling. If log includes
errorproperty with Error instance, usescaptureExceptionfor better stack traces.5. Modern Sentry v8+ API Pattern (lines 272-278)
Uses global functions instead of client instances, following Sentry Best Practices:
6. Additional Enhancements
sentry.origin,category,timestampAPI
Backward compatibility: Existing code continues to work unchanged. Client parameter shows deprecation warning but remains functional.
Impact
Quality
deno check)deno lint)deno fmt)@logtape/sentrypattern - Sentry SDK difficult to mock meaningfully)Files Changed
Dependencies: None added. Uses existing
@sentry/coreand@logtape/logtape.Questions for Review
trueorfalse? (Currentlyfalseto avoid noise)